/*
 * @Author: cola(sunshiwen)
 * @Date: 2022-04-22 09:57:27
 * @LastEditTime: 2022-07-17 17:49:50
 * @LastEditors: cola(sunshiwen)
 * @Description: 分支管理参数 schema
 * @FilePath: /maycur-koa/schema/branch_manage_schema.js
 */
'use strict';

const Joi = require('@hapi/joi');
// 主分支
const fetchMasterBranchListSchema = {
    router: Joi.object({
        pid: Joi.string().required(),
    }),
};
const addNewMasterBranchSchema = {
    body: Joi.object({
        version: Joi.string().required(),
        pid: Joi.string().required(),
        commitId: Joi.string().required(),
    }),
}
const updateMasterBranchSchema = {
    body: Joi.object({
        version: Joi.string().required(),
        pid: Joi.string().required(),
        commitId: Joi.string().required(),
    }),
}

// 混合云分支
const fetchHybridBranchListSchema = {
    router: Joi.object({
        pid: Joi.string().required(),
    }),
};
const addNewHybridBranchSchema = {
    body: Joi.object({
        corporation: Joi.string().required(),
        env: Joi.string().required(),
        branch: Joi.string().required(),
        version: Joi.string().required(),
        nextVersion: Joi.string().empty("").default(""),
        pid: Joi.string().required(),
        commitId: Joi.string().empty("").default(""),
        remark: Joi.string().empty("").default(""),
    }),
}
const updateHybridBranchSchema = {
    body: Joi.object({
        pid: Joi.string().required(),
        branch: Joi.string().required(),
        version: Joi.string().required(),
        nextVersion: Joi.string().empty("").default(""),
        commitId: Joi.string().empty("").default(""),
        remark: Joi.string().empty("").default(""),
        id: Joi.number().required(),
    }),
}

const deleteHybridBranchSchema = {
    router: Joi.object({
        id: Joi.string().required(),
    }),
}

module.exports = {
    fetchMasterBranchList: fetchMasterBranchListSchema,
    addNewMasterBranch: addNewMasterBranchSchema,
    updateMasterBranch: updateMasterBranchSchema,
    fetchHybridBranchList: fetchHybridBranchListSchema,
    addNewHybridBranch: addNewHybridBranchSchema,
    updateHybridBranch: updateHybridBranchSchema,
    deleteHybridBranch: deleteHybridBranchSchema,
}